package graduation.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import graduation.entity.Suggestion;
import graduation.service.SuggestionService;
import graduation.utils.ResultVOUtil;
import graduation.vo.PageVO;
import graduation.vo.ResultVO;

@Controller
@RequestMapping("/suggestion")
public class SuggestionController {
	@Autowired
	private SuggestionService suggestionServiceImpl;
	
	/**
	 * 添加到数据库
	 * @param title
	 * @param info
	 * @return
	 */
	@RequestMapping(value="addSuggestion",method=RequestMethod.POST)
	@ResponseBody
	public ResultVO addSuggestion(@RequestBody Suggestion suggestion
							){
//		Suggestion suggestion = new Suggestion();
//		suggestion.setInfo(info);
//		suggestion.setTitle(title);
		//添加到数据库
		suggestionServiceImpl.addSuggestion(suggestion);
		return ResultVOUtil.success("成功",suggestion);
		
	}
	
	
	@RequestMapping(value="getAllSuggestion",method=RequestMethod.GET)
	@ResponseBody
	public ResultVO getAllSuggestion(@RequestParam("page") int page,
			@RequestParam("size") int size){
		PageVO pageVo = suggestionServiceImpl.getAllSuggestion(page,size);
		//添加到数据库
		return ResultVOUtil.success("成功",pageVo);
		
	}
}
